﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Composite.Regions;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Composite.Events;
using Might.Infrastructure.Services;

namespace Might.ProgressService {
    public class ProgressServiceModule : IModule {
        private IRegionManager regionManager;
        private IUnityContainer container;
        private IEventAggregator eventAggregator;

        private ProgressService progressService;
        private StatusBarPresenter presenter;

        public ProgressServiceModule(
            IUnityContainer container, IRegionManager regionManager, IEventAggregator eventAggregator) {
            this.regionManager = regionManager;
            this.container = container;
            this.eventAggregator = eventAggregator;
        }

        public void Initialize() {
            container.Resolve<IMightLogger>().Log(this, "Status bar module init");

            progressService = new ProgressService(eventAggregator);
            container.RegisterInstance<IProgressService>(progressService);

            var view = container.Resolve<StatusBarView>();
            presenter = new StatusBarPresenter(container, eventAggregator) {View = view};
            IRegion statusBarRegion = regionManager.Regions["StatusBarRegion"];
            statusBarRegion.Add(view);
        }
    }
}
